<%--
  Created by IntelliJ IDEA.
  User: 86175
  Date: 2021/8/4
  Time: 19:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"  %>
<html>
<head>
    <title>修改奖牌数</title>
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script>
        function alterMedal(id) {
            var param = {
                'id' :id,
                'gold':$("#gold").val(),
                'silver':$("#silver").val(),
                'copper':$("#copper").val(),
                'ram' :Math.random()
            }
            $.getJSON("AlterMedalServlet",param,function (data){
                alert(data);
                window.location.href='index.jsp';
            })
        }
    </script>
</head>
<body>
<div class="container">

    <h3>修改奖牌数</h3>
    <table class="table table-bordered text-center">
        <tr class="text-center bg-primary">
            <td>国家</td>
            <td>金牌数</td>
            <td>银牌数</td>
            <td>铜牌数</td>
            <td colspan="2">操作</td>
        </tr>
        <c:forEach var="country" items="${country}">

            <tr>
                <td>${country.country}</td>
                <td><input type="text" class="form-control" value="${country.gold}" id="gold" name="gold"></td>
                <td><input type="text" class="form-control" value="${country.silver}" id="silver" name="silver"> </td>
                <td><input type="text" class="form-control" value="${country.copper}" id="copper" name="copper"> </td>
                <td><a id="${country.id}" onclick="alterMedal(this.id)" class="btn btn-danger">修改</a> </td>
                <td><a href="index.jsp" class="btn btn-primary">返回</a> </td>
<%--                <input type="hidden" name="id" value="${country.id}">--%>
<%--                <input type="hidden" id="gold" value="${country.gold}">--%>
<%--                <input type="hidden" id="silver" value="${country.silver}">--%>
<%--                <input type="hidden" id="copper" value="${country.copper}">--%>
<%--                <td><input type="button" value="修改" class="btn btn-primary" onclick="alterMedal(this.id,this.gold,this.silver,this.copper)" ></td>--%>
<%--                <td><input type="submit" value="修改" class="btn btn-primary"></td>--%>
            </tr>
        </c:forEach>
    </table>
        <div id="tip" class="text-center text-danger"></div>

</div>

</body>
</html>
